import request from "@/utils/request";

// 根据用户id ---> 获取对应的菜单信息
export const getRouters = (userId) => {
    return request({
        url: `/menu/fetchMenusForRole/${userId}`,
        method: 'GET'
    })
}

// 角色信息 --- 对应的菜单权限
export const getRoleInfo = () => {
    return request({
        url: `/menu/fetchMenusForRole`,
        method: 'GET'
    })
}

// 根据父级菜单Id ---> 获取子菜单列表
export const getMenuChildInfo = (parentId) => {
    return request({
        url: `/menu/fetchAllMenus`,
        method: 'GET',
        params: {
            parentId: parentId
        }
    })
}

// 获取全部父级菜单
export const getAllParentMenu = () => {
    return request({
        url: `/menu/fetchAllParentMenus`,
        method: 'GET'
    })
}


// 编辑角色菜单权限
export const editRoleMenu = (roleId, menuRole) => {
    return request({
        url: `/menu/editRoleMenu`,
        method: 'POST',
        params: {
            roleId: roleId,
            menuRole: menuRole
        }
    })
}

// 添加角色
export const addRoleInfo = (data) => {
    return request({
        url: `/menu/addRole`,
        method: 'POST',
        data: data
    })
}

// 获取所有角色信息
export const getAllRoleInfo = () => {
    return request({
        url: `/menu/getAllRole`,
        method: 'GET'
    })
}

// 编辑用户对应的角色信息
export const editUserRole = (data) => {
    return request({
        url: `/menu/editUserRole`,
        method: 'PUT',
        data: data
    })
}